package day3


trait  HelloTrait{
  def sayHelloTrait(name:String)

  def printLog():Unit ={
    println("正在打印日志中....")
  }
}

trait  MakeFriendsTrait{
  def makeFriends(w:Worker)
}


class Worker(var name : String) extends HelloTrait with MakeFriendsTrait{
  override def sayHelloTrait(name: String): Unit = println("hello" + name)

  override def makeFriends(w: Worker): Unit = println("Hi:" + w.name)
}

object TraitDemo {
  def main(args: Array[String]): Unit = {
    val nan = new Worker("nan")
    nan.sayHelloTrait("nihao")
    nan.makeFriends(nan)
    nan.printLog
  }
}


